function delay(duration) {
  var start = Date.now()
  while (Date.now() - start < duration) { }
}
setTimeout(() => {
  console.log('1');
}, 0)

delay(3000)

console.log(2);

// 等待3秒，然后同时输出 2 1